@include('admin.public.head')

<div class="ibox-title">
    <h5>用户编辑</h5>
</div>

<div class="ibox-content">
    <form  class="form-horizontal">

        <div class="form-group">
            <label class="col-sm-3 control-label">手机号：</label>
            <div class="col-sm-3">
                <input type="text" name="phone" class="form-control" placeholder="手机号" value="{{$result->phone}}">
            </div>
        </div>
        <div class="hr-line-dashed"></div>

        <div class="form-group">
            <label class="col-sm-3 control-label">姓名：</label>
            <div class="col-sm-3">
                <input type="text" name="name" class="form-control" placeholder="姓名" value="{{$result->name}}">
            </div>
        </div>
        <div class="hr-line-dashed"></div>

        <div class="form-group">
            <label class="col-sm-3 control-label">会员编号：</label>
            <div class="col-sm-3">
                <input type="text" name="user_number" class="form-control" placeholder="会员编号" value="{{$result->user_number}}">
            </div>
        </div>
        <div class="hr-line-dashed"></div>

        <input type="hidden" name="id" value="{{$id??0}}">

        <div class="form-group">
            <div class="col-sm-4 col-sm-offset-3">
                <a class="btn btn-primary do" type="submit">操作</a>
                <a href="/user_lists" class="btn btn-primary" >返回用户列表</a>
            </div>
        </div>
    </form>
</div>
<script>
    $('.do').click(function(){
        var form = new FormData();

        var phone = $('input[name="phone"]').val();
        var name = $('input[name="name"]').val();
        var user_number = $('input[name="user_number"]').val();
        var id = $('input[name="id"]').val();

        form.append("phone", phone);
        form.append("name", name);
        form.append("user_number", user_number);
        form.append("id", id);

        $.ajax({
            type: 'POST',
            url: '/user_do' ,
            dataType:"json",   //返回格式为json
            data: form ,
            processData: false,
            contentType: false,
            success:function(data){

                if(data.status == '1') {
                    var swal_json = {
                        title: data.message,
                        type: "success"
                    }

                    swal(swal_json, function (isConfirm) {
                        //window.location.reload();
                    });

                }else{
                    var swal_json = {
                        title: data.message,
                        type: "error"
                    }

                    swal(swal_json, function (isConfirm) {

                    });
                }
            }
        });

        return false;
    });

</script>
